package com.ibl.rover.lite.common.bean;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

public class OrderBean extends BaseBean {

	@ColumnOrder(Order = 1)
	private String orderId;
	@ColumnOrder(Order = 2)
	private String customerCode;
	@ColumnOrder(Order = 3)
	private String date;
	@ColumnOrder(Order = 4)
	private String amount;
	@ColumnOrder(Order = 5)
	private String isActive;
	@ColumnOrder(Order = 6)
	private String status;
	@ColumnOrder(Order = 7)
	private String salesType;

	private static AutomatedQueryStatement AUTO_GEN_QUERY;

	public static final String COL_ORDER_ID = "ORDER_ID";
	public static final String COL_CUSTOMER_CODE = "CUSTOMER_CODE";
	public static final String COL_DATE = "DATE";
	public static final String COL_AMOUNT = "AMOUNT";
	public static final String COL_IS_ACTIVE = "IS_ACTIVE";
	public static final String COL_STATUS = "STATUS";
	public static final String COL_SALES_TYPE = "SALES_TYPE";

	public static final int IDX_COL_ORDER_ID = 1;
	public static final int IDX_COL_CUSTOMER_CODE = 2;
	public static final int IDX_COL_DATE = 3;
	public static final int IDX_COL_AMOUNT = 4;
	public static final int IDX_COL_IS_ACTIVE = 5;
	public static final int IDX_COL_STATUS = 6;
	public static final int IDX_COL_SALES_TYPE = 7;

	static {
		AUTO_GEN_QUERY = SQLiteDatabaseHelper
				.getAutoGeneratedStmts(OrderBean.class);
	}

	public OrderBean() {

	}

	@Override
	public void bind(SQLiteStatement sqlLiteStatement) {
		sqlLiteStatement.bindString(IDX_COL_ORDER_ID, getOrderId());
		sqlLiteStatement.bindString(IDX_COL_CUSTOMER_CODE, getCustomerCode());
		sqlLiteStatement.bindString(IDX_COL_DATE, getDate());
		sqlLiteStatement.bindString(IDX_COL_AMOUNT, getAmount());
		sqlLiteStatement.bindString(IDX_COL_IS_ACTIVE, getIsActive());
		sqlLiteStatement.bindString(IDX_COL_STATUS, getStatus());
		sqlLiteStatement.bindString(IDX_COL_SALES_TYPE, getSalesType());

	}

	@Override
	public <T extends BaseBean> T cursorBind(Cursor cursor) {
		OrderBean orderBean = new OrderBean();
		orderBean.set_id(cursor.getInt(IDX_COL_ID));
		orderBean.setCustomerCode(cursor.getString(IDX_COL_CUSTOMER_CODE));
		orderBean.setAmount(cursor.getString(IDX_COL_AMOUNT));
		orderBean.setDate(cursor.getString(IDX_COL_DATE));
		orderBean.setIsActive(cursor.getString(IDX_COL_IS_ACTIVE));
		orderBean.setOrderId(cursor.getString(IDX_COL_ORDER_ID));
		orderBean.setSalesType(cursor.getString(IDX_COL_SALES_TYPE));
		orderBean.setStatus(cursor.getString(IDX_COL_STATUS));

		return (T) orderBean;
	}

	@Override
	public <T extends BaseBean> T cursorInit(Cursor cursor) {
		this.set_id(cursor.getInt(IDX_COL_ID));
		this.setCustomerCode(cursor.getString(IDX_COL_CUSTOMER_CODE));
		this.setAmount(cursor.getString(IDX_COL_AMOUNT));
		this.setDate(cursor.getString(IDX_COL_DATE));
		this.setIsActive(cursor.getString(IDX_COL_IS_ACTIVE));
		this.setOrderId(cursor.getString(IDX_COL_ORDER_ID));
		this.setSalesType(cursor.getString(IDX_COL_SALES_TYPE));
		this.setStatus(cursor.getString(IDX_COL_STATUS));

		return (T) this;
	}

	@Override
	public String getCreateTableQuery() {

		return AUTO_GEN_QUERY.getCreateTableQuery();
	}

	@Override
	public String getInsertQuery() {

		return AUTO_GEN_QUERY.getPreparedInsertQuery();
	}

	@Override
	public String getDeleteQuery() {

		return AUTO_GEN_QUERY.getPreparedDeleteQuery();
	}

	@Override
	public String getUpdateQuery() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getTableName() {

		return AUTO_GEN_QUERY.getTableName();
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public String getCustomerCode() {
		return customerCode;
	}

	public void setCustomerCode(String customerCode) {
		this.customerCode = customerCode;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getAmount() {
		return amount;
	}

	public void setAmount(String amount) {
		this.amount = amount;
	}

	public String getIsActive() {
		return isActive;
	}

	public void setIsActive(String isActive) {
		this.isActive = isActive;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getSalesType() {
		return salesType;
	}

	public void setSalesType(String salesType) {
		this.salesType = salesType;
	}

	@Override
	public ContentValues bindContentValues() {
		 ContentValues  contentValues=new ContentValues();
		 contentValues.put(COL_AMOUNT,amount );
		 contentValues.put(COL_CUSTOMER_CODE,customerCode );
		 contentValues.put(COL_DATE,date );
		 contentValues.put(COL_IS_ACTIVE, isActive);
		 contentValues.put(COL_ORDER_ID,orderId );
		 contentValues.put(COL_SALES_TYPE, salesType);
		 contentValues.put(COL_STATUS,status );
		return contentValues;
	}

}
